// pages/visit/visit.js
import {visitorModel} from '../../../model/visitorBuy'

var http = new visitorModel()

Page({
  /**
   * 页面的初始数据
   */
  data: {
    navbarActiveIndex_1:0,
    navbarActiveIndex_2:0,
    navbarActiveIndex_3:0,
    visitCount:{
      day:2,
      month:2,
      sum:2,
    },
    trade:{
      sum:2344,
      count:2,
    },
    navbarTitle_1:[
      {title:'我的访客',iconY:'/static/footY.png',iconN:'/static/footN.png'},
      {title:'我的团队',iconY:'/static/teamN.png',iconN:'/static/teamY.png'},
    ],
    navbarTitle_2:[
      {title:'访问记录',iconY:'/static/line_x.png',iconN:''},
      {title:'购买记录',iconY:'',iconN:'/static/line_x.png'},
    ],
    navbarTitle_3:[
      {title:'团队成员',iconY:'/static/line_x.png',iconN:''},
      {title:'团队销量',iconY:'',iconN:'/static/line_x.png'},
    ],
    FKbuyList:{},
    FKlist:{},
    TDbuyList:{},
    TDlist:{}
  },
  getVisitorBuy(){
    http.visitorBuy('','',0).then(
      res =>{
        console.log("11111111")
        console.log(res)
        this.setData({
          FKbuyList: res.data
        })
      }
    )
  },
  getVisitor1(){
    http.visitor('','',0).then(
      res =>{
        console.log("2222222")
        console.log(res)
        this.setData({
          FKlist: res.data
        })
      }
    )
  },
  getVisitorBuy1(){
    http.visitorBuy('','',1).then(
      res =>{
        console.log("33333333")
        console.log(res)
        this.setData({
          TDbuyList: res.data
        })
      }
    )
  },
  getVisitor(){
    http.visitor('','',1).then(
      res =>{
        console.log("444444444")
        console.log(res)
        this.setData({
          TDlist: res.data
        })
      }
    )
  },
  //  test
  testFunction(){
    console.log(this.data.FKlist)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  },


  onNavBarTap_1: function (event) {
    // 获取点击的navbar的index
    let navbarTapIndex = event.currentTarget.dataset.navbarIndex
    // 设置data属性中的navbarActiveIndex为当前点击的navbar
    this.setData({
      navbarActiveIndex_1: navbarTapIndex
    })
  },

  onNavBarTap_2: function (event) {
    // 获取点击的navbar的index
    let navbarTapIndex = event.currentTarget.dataset.navbarIndex
    // 设置data属性中的navbarActiveIndex为当前点击的navbar
    this.setData({
      navbarActiveIndex_2: navbarTapIndex
    })
    if (navbarTapIndex===0) {
      this.getVisitor1()
    } else {
      this.getVisitorBuy()
    }
   
  },

  onNavBarTap_3: function (event) {
    // 获取点击的navbar的index
    let navbarTapIndex = event.currentTarget.dataset.navbarIndex
    // 设置data属性中的navbarActiveIndex为当前点击的navbar
    this.setData({
      navbarActiveIndex_3: navbarTapIndex
    })
    if (navbarTapIndex===0) {
      this.getVisitor()
    } else {
      this.getVisitorBuy1()
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onShow: function (){
    this.getVisitorBuy()
    this.getVisitor()
    this.getVisitorBuy1()
    this.getVisitor1()
  }
  /**
   * 生命周期函数--监听页面显示
   */

  /**
   * 生命周期函数--监听页面隐藏
   */

  /**
   * 生命周期函数--监听页面卸载
   */

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  
  /**
   * 页面上拉触底事件的处理函数
   */

  /**
   * 用户点击右上角分享
   */

})